﻿#include "Complex.h"

Complex::Complex()
{
	_real = 0.0;
	_image = 0.0;
}


Complex::Complex(const Complex& x)
{
	_real = x._real;
	_image = x._image;
	cout << "Complex Copy构造()" << endl;
}


Complex Complex::operator+(const Complex& x) const {
	//Complex t;
	//t._real = _real + x._real;
	//t._image = _image + x._image;
	// typename() : 创建临时对象
	return Complex(_real+x._real, _image+x._image);
}

Complex& Complex::operator=(const Complex& x) {
	if (this != &x) {
		_real = x._real;
		_image = x._image;
	}
	// 返回当前对象引用
	return *this;
}

Complex& Complex::operator+=(const Complex& x)
{
	// this 当前对象的指针
	return _doPlus(this, x);
}

bool Complex::operator==(const Complex& x) const {
	return _real == x._real && _image == x._image;
}

Complex& Complex::operator++()
{
	_real++;
	_image++;
	return *this;
}

Complex Complex::operator++(int)
{
	// 直接使用构造 不产生临时对象
	return Complex(_real++, _image++);
}



